//导航列表
let db = require("../db/index")

const navList = (req, res) => {
    var sql = 'select * from navigation'
    db.query(sql, (err, result) => {
        if (err) {
            // return res.send('错误：' + err.message)
            res.json({
                code: "0",
                msg: err
            });
            return
        } else {
            // res.send(result)
            res.json({
                code: "1",
                msg: "操作成功",
                result: result
            })
        }
    })
}

const search = (req, res) => {
    var mz = "%" + req.body.search + "%";
    var sql = `SELECT * FROM videolist WHERE NAME LIKE ?`
    db.query(sql, [mz], (err, result) => {
        console.log(err, result, 'result');
        if (err) {
            // return res.send('错误：' + err.message)
            res.json({
                code: "0",
                msg: err
            });
            return
        } else {
            // res.send(result)
            res.json({
                code: "1",
                msg: "操作成功",
                result: result
            })
        }
    })
}
module.exports = {
    navList, search
}
